package org.jluzhCS.mylogin.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.jluzhCS.mylogin.domain.User;

import com.sun.org.apache.bcel.internal.generic.RETURN;

public class UserService
{

    static List<User> userDb;

    // ģ���û����ݿ�
    static
    {
	userDb = new ArrayList<>();
	userDb.add(new User(1, "sun", "123", "admin"));
	userDb.add(new User(2, "kaka", "123", "customer"));
	userDb.add(new User(3, "lily", "123", "admin"));
	userDb.add(new User(4, "tom", "123", "customer"));
    }

    public Integer ValidLogin(User user)
    {
	for (User u : userDb)
	{
	    if (u.equals(user))
		if (u.getType().equals(user.getType()))
		    return u.getId();
	}
	return -1;
    }

    public List<User> getAllUser()
    {
	return userDb;
    }
}
